const request = require('../../../utils/https.js')
var userId;
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    const that=this;
    userId = wx.getStorageSync('userId');
    if (userId == '' || userId == null || userId == 'undefined') {
      userId = "5f60324fd964428782e187751da3e190";
    }
    //用户信息
    request._get(getApp().Api_url + 'user/getMainInfo', {
      userId: userId,
    }, function (res) {
      if (res.data.errMsg == 'OK') {
        console.log('****==>', res.data.data)
        let mainInfo = res.data.data;
        let className;
        if (mainInfo.rankNum == 0) {
          className = 'green';
        } else if (mainInfo.rankNum == 1) {
          className = 'pink';
        } else if (mainInfo.rankNum == 2) {
          className = 'purple';
        } else if (mainInfo.rankNum == 3) {
          className = 'golden';
        }
        that.setData({
          mainInfo: mainInfo,
          className: className,
          takeMoney: Number(mainInfo.takeMoney).toFixed(2),
          poorMoney: Number(mainInfo.rankMoney - mainInfo.takeMoney).toFixed(2)
        })

      }
    }, function () { })
        //三张图片
        request._get(getApp().Api_url + 'user/memberCenter', {
          userId: userId
        }, function (res) {
          if (res.data.code == 200) {
            console.log('三张图片====>', res.data.data)
            that.setData({
              memberCenter:res.data.data
            })
    
          }
        }, function () { });
  },
  goVIP (e) {
    let urlId = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/packageA/pages/VIP/VIP?urlId=' + urlId + '&url=VIP'
    })
  },
  goSVIP (e) {
    let urlId = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/packageA/pages/VIP/VIP?urlId=' + urlId + '&url=SVIP'
    })
  },
  goAgent () {
    wx.navigateTo({
      url: '/packageB/pages/agent/agent'
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})